package com.zyh.system.JDsupermarkt.controller;

import com.zyh.system.JDsupermarkt.dao.impl.BuyCarDaoImpl;
import com.zyh.system.JDsupermarkt.dao.impl.GoodsDaoImpl;
import com.zyh.system.JDsupermarkt.domain.BuyCar;
import com.zyh.system.JDsupermarkt.domain.Goods;
import com.zyh.system.JDsupermarkt.service.impl.BuyCarServiceImpl;
import com.zyh.system.JDsupermarkt.service.impl.GoodsServiceImpl;

import java.util.LinkedHashMap;
import java.util.Scanner;

/**
 * @Author zyh
 * @Date 2024/8/2 17:04
 * @Description 商城首页    使用：LinkedHashMap
 */

public class Index {
    public static final Scanner INPUT=new Scanner(System.in);
    public static final LinkedHashMap<Integer, Goods> GOODS_MAP= GoodsDaoImpl.GOODS_MAP;
    public static final LinkedHashMap<Integer, BuyCar> BUY_CAY= BuyCarDaoImpl.BUY_CAR;
    public static final GoodsServiceImpl GOODS_SERVICE=new GoodsServiceImpl();
    public static final BuyCarServiceImpl BUY_CAR_SERVICE=new BuyCarServiceImpl();
    public static void main(String[] args) {
        while (true) {
            System.out.println("*****欢迎进入京东商城******");
            System.out.println("1.添加商品");
            System.out.println("2.查看所有商品");
            System.out.println("3.查看指定编号商品");
            System.out.println("4.修改指定编号商品");
            System.out.println("5.删除商品");
            System.out.println("6.添加到购物车");
            System.out.println("7.显示购物车");
            System.out.println("8.删除购物车中的商品");
            System.out.println("9.退出");
            System.out.println("*************************");
            System.out.println("请选择：");
            int choice = INPUT.nextInt();
            switch (choice){
                case 1://添加商品
                    GOODS_SERVICE.addGoods(GOODS_MAP);
                    break;
                case 2://查看所有商品
                    GOODS_SERVICE.showAll(GOODS_MAP);
                    break;
                case 3://查看指定编号商品
                    GOODS_SERVICE.selectById(GOODS_MAP);
                    break;
                case 4://修改指定编号商品
                    GOODS_SERVICE.updateById(GOODS_MAP);
                    break;
                case 5://删除商品
                    GOODS_SERVICE.deleteById(GOODS_MAP);
                    break;
                case 6://添加到购物车
                    BUY_CAR_SERVICE.addBuyCar(GOODS_MAP);
                    break;
                case 7://显示购物车
                    BUY_CAR_SERVICE.showBuyCay(BUY_CAY);
                    break;
                case 8://删除购物车中的商品
                    BUY_CAR_SERVICE.deleteById(BUY_CAY);
                    break;
                default:
                    System.out.println("系统退出");
                    System.exit(0);
            }
        }
    }
}
